// 路由按需加载,第三个参数作为打包包名使用
const Home = r => require.ensure([], () => r(require('@/pages/home/home.vue')), 'home')
const user = r => require.ensure([], () => r(require('@/pages/user/index.vue')), 'user')
const role = r => require.ensure([], () => r(require('@/pages/role/index.vue')), 'role')
const menu = r => require.ensure([], () => r(require('@/pages/menu/index.vue')), 'menu')
const department = r => require.ensure([], () => r(require('@/pages/department/index.vue')), 'department')
const editUser = r => require.ensure([], () => r(require('@/pages/editUser/index.vue')), 'editUser')
const login = r => require.ensure([], () => r(require('@/pages/login/index.vue')), 'login')
const page404 = r => require.ensure([], () => r(require('@/components/error-page/404.vue')), '404')
const page403 = r => require.ensure([], () => r(require('@/components/error-page/403.vue')), '403')
const page500 = r => require.ensure([], () => r(require('@/components/error-page/500.vue')), '500')
const routes = [
  {
    path: '/',
    name: 'root',
    redirect: '/home',
    meta: {
      hideInMenu: true
    }
  },
  {
    path: '/login',
    name: 'login',
    component: login,
    meta: {
      hideInMenu: true
    }
  },
  {
    path: '/home',
    name: 'home',
    component: Home,
    redirect: '/home/user',
    meta: {
      title: '权限管理',
    },
    children: [{
      path: 'user',
      name: 'user',
      component: user,
      meta: {
        keepAlive: false,
        title: '用户管理',
        access: 'user'
      }
    }, {
      path: 'role',
      name: 'role',
      component: role,
      meta: {
        keepAlive: false,
        title: '角色管理',
        access: 'role'
      }
    }, {
      path: 'menu',
      name: 'menu',
      component: menu,
      meta: {
        keepAlive: false,
        title: '菜单管理',
        access: 'menu'
      }
    }, {
      path: 'department',
      name: 'department',
      component: department,
      meta: {
        keepAlive: false,
        title: '部门管理',
        access: 'department'
      }
    }, {
      path: 'editUser/:id?',
      name: 'editUser',
      component: editUser,
      meta: {
        keepAlive: false,
        hideInMenu: true
      }
    }]
  },
  {
    path: '/404',
    component: page404,
    name: '404',
    meta: {
      hideInMenu: true
    }
  },
  {
    path: '/403',
    component: page403,
    name: '403',
    meta: {
      hideInMenu: true
    }
  },
  {
    path: '/500',
    component: page500,
    name: '500',
    meta: {
      hideInMenu: true
    }
  },
  {
    path: '*',
    redirect: '/404',
    meta: {
      hideInMenu: true
    }
  }
]

export default routes
